<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../commons/commons.jsp" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<base href="<%=basePath%>">
	
	<title>Login</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script src="../../layer/layer.js"></script>
	</head>
	<body>
		<div align="center">
	    	<div><h2>登录系统</h2></div>
	    	<form action="user/main.html" method="post" id="_form">
	    	<table align="center">
		    	<tr><td>登录账户:</td><td><input type="text" name="username" id="username" onchange="checkUsername()" /><span id="sp1"></span></td></tr>
		    	<tr><td>登录密码:</td><td><input type="password" name="password" id="password" onchange="checkPassword()" /><span id="sp2"></span></td></tr>
	    		<tr align="center">
	    			<td colspan="10">
	    			<input type="button" value="登录" onclick="login()" >
	    			<input type="button" value="注册用户" onclick="register()" >
	    			</td>
	    		</tr>
	    	</table>
	    	</form>
	    </div>
	   <script type="text/javascript">
	   		function login(){
	   			if(check()){
		   			$("#_form").submit();
	   			}
	   		}
			function register(){
				layer.open({
					type: 2,
					area: ['800px', '500px'],
					title: false,
					shade: 0.6,
					anim: 1,
					content: 'user/toUser'
				});
			}
			function check(){
		  		if(checkUsername()&checkPassword()){
		  			return true;
		  		}else {
		  			return false;
		  		}
		  	}
			function checkUsername(){
				var username = $("#username").val();
				if(username==""){
					$("#sp1").html("<font color='green'>用户名不能为空</font>");
					return false;
				}else{
					$("#sp1").html("");
					return true;
				}
			}
			function checkPassword(){
				var password = $("#password").val();
				if(password==""){
					$("#sp2").html("<font color='green'>密码不能为空</font>");
					return false;
				}else{
					$("#sp2").html("");
					return true;
				}
			}
	   </script>
	</body>
</html>
